package com.summer.order.controller;

import java.io.Serializable;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;

import com.summer.core.annotations.ScopeType;
import com.summer.core.controller.EntityQuery;
import com.summer.order.model.Food;


@Component
@Scope(ScopeType.VIEW)
public class FoodList extends EntityQuery<Food> implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private List<Food> foodList;
	@Resource
	HibernateTemplate ht;
	
	private final String HQL = "select food from Food food";
	private final String COUNT_HQL = "select count(food) from Food food";
	
	public FoodList() {
		
		setCountHql(COUNT_HQL);
		setHql(HQL);
	}
	

	public List<Food> getFoodList() {
		if(foodList == null) {
			foodList = ht.find("select food from Food food");
		}
		return foodList;
	}

	public void setFoodList(List<Food> foodList) {
		this.foodList = foodList;
	}
	
	
}
